<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-CN">
<%@include file="/WEB-INF/include-head.jsp" %>
<body>
<%@ include file="/WEB-INF/include-nav.jsp" %>
<div class="container-fluid">
    <div class="row">
        <%@ include file="/WEB-INF/include-sidebar.jsp" %>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <ol class="breadcrumb">
                <li><a href="/admin/main">首页</a></li>
                <li><a href="/admin/authority/user/list">数据列表</a></li>
                <li class="active">修改</li>
            </ol>
            <c:if test="${requestScope.exception != null}">
                <div class="alert alert-danger">${requestScope.exception.message}</div>
            </c:if>
            <div class="alert alert-danger hidden" id="form-message"></div>
            <div class="panel panel-default">
                <div class="panel-heading">表单数据</div>
                <div class="panel-body">
                    <form role="form" action="/admin/authority/user/update" id="admin-form" method="post">
                        <input type="hidden" id="id" name="id" value="${admin.id}">
                        <div class="form-group">
                            <label for="loginAcct">账号</label>
                            <input type="text" class="form-control" name="loginAcct" id="loginAcct" placeholder="账号" value="${admin.loginAcct}" readonly required>
                        </div>
                        <div class="form-group">
                            <label for="userPswd">密码</label>
                            <input type="password" class="form-control" name="userPswd" id="userPswd" placeholder="密码" minlength="3">
                        </div>
                        <div class="form-group">
                            <label for="userPswd2">再次输入密码</label>
                            <input type="password" class="form-control" name="userPswd2" id="userPswd2" placeholder="密码" minlength="3">
                        </div>
                        <div class="form-group">
                            <label for="userName">昵称</label>
                            <input type="text" class="form-control" name="userName" id="userName" placeholder="昵称" value="${admin.userName}" required>
                        </div>
                        <div class="form-group">
                            <label for="email">邮箱</label>
                            <input type="email" class="form-control" name="email" id="email" placeholder="邮箱" value="${admin.email}" required>
                        </div>
                        <button type="submit" class="btn btn-success"><i class="glyphicon glyphicon-pencil"></i>修改</button>
                        <button type="reset" class="btn btn-danger"><i class="glyphicon glyphicon-refresh"></i>重置</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="static/jquery/jquery.validate.min.js"></script>
<script src="static/jquery/messages_zh.js"></script>
<script src="static/jquery/jquery-form.min.js"></script>
<script>
    $('#admin-form').submit(function () {
        let messageDom = $('#form-message');
        let password1 = $('#userPswd').val();
        let password2 = $('#userPswd2').val();

        if (password1 == "" && password2 == "") {
            return true;
        }
        if (password1 !== password2) {
            messageDom.text('两次密码不一致');
            messageDom.removeClass('hidden');
            return false;
        }
    });
</script>
</body>
</html>
